﻿// Genius
// Copyright (C) 2016 Dirk Friedenberger, www.frittenburger.de
//   
// This source file is subject to the Microsoft Public License (Ms-PL).
// http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.
using Genius.Brain.Shared.BO;
using Genius.Brain.Shared.Locator;
using Genius.SlackBot.Shared.Converter;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Genius.SlackBot.Impl.Converter
{
    class JsonToMessageConverter : IConverter<JToken, IMessage>
    {
        public IMessage ConvertFrom(JToken json)
        {
            var message = BrainLocator.GetMessage();

            message.ChannelId = json["channel"].Value<string>();
            message.Text = json["text"].Value<string>();
            message.User = json["user"].Value<string>();

            return message;
        }
    }
}
